import requests
import json
url1='http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do?method=getXkzsList'
url2='http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do?method=getXkzsById'
header={'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'}
id_list=[]
all_data_list=[]
for i in range(10):
    page=str(i)
    data={
    'on':'true',
    'page':page,
    'pageSize':'15',
    'productName':'',
    'conditionType':'1',
    'applyname':'',
    'applysn':''
    }
    json_ids=requests.post(url=url1,data=data,headers=header).json()
    for item in json_ids['list']:
        id_list.append(item['ID'])
for id in id_list:
    data={'id': id}
    res=requests.post(url=url2,data=data,headers=header).json()
    all_data_list.append(res)

filename= '药监局数据.json'
with open(filename,'w') as fn:
    json.dump(all_data_list,fn,ensure_ascii=False)
print('end!')